package com.meida.module.bus.provider.service.impl.srm;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.bus.client.entity.srmapi.basedata.SrmPurchaseorder;
import com.meida.module.bus.provider.mapper.srm.SrmPurchaseorderMapper;
import com.meida.module.bus.provider.service.srmservice.SrmPurchaseorderService;
import org.apache.commons.compress.utils.Lists;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * srm采购订单数据接口实现类
 *
 * @author flyme
 * @date 2020-10-15
 */
@Service
@Transactional(rollbackFor = Exception.class)
@DS("dbr")
public class SrmPurchaseorderServiceImpl extends BaseServiceImpl<SrmPurchaseorderMapper, SrmPurchaseorder> implements SrmPurchaseorderService {

    @Override
    public void afterPageList(CriteriaQuery<SrmPurchaseorder> cq, List<EntityMap> data, ResultBody resultBody) {
        List<EntityMap> outDatas = Lists.newArrayList();
        data.stream().forEach(obj->{
            obj.put("purchaseorderId", obj.get("PURCHASEORDERID"));
            obj.put("purchaseorderNo", obj.get("PURCHASEORDERNO"));
            obj.put("purchaseorderType", obj.get("PURCHASEORDERTYPE"));
            obj.put("erppurchaseOrderno", obj.get("ERPPURCHASEORDERNO"));
            obj.put("purchaseorderTime", obj.get("PURCHASEORDERTIME"));
            obj.put("purchasingOrgName", obj.get("PURCHASINGORGNAME"));
            obj.put("vendorCode", obj.get("VENDORCODE"));
            obj.put("vendorName", obj.get("VENDORNAME"));
            obj.put("companyCode", obj.get("COMPANYCODE"));
            obj.put("companyName", obj.get("COMPANYNAME"));
            obj.put("currencyCode", obj.get("CURRENCYCODE"));
            obj.put("currencyName", obj.get("CURRENCYNAME"));
            obj.put("currencyRate", obj.get("CURRENCYRATE"));
            obj.put("totalAmount", obj.get("TOTALAMOUNT"));
            obj.put("uploadfileGroupId", obj.get("UPLOADFILEGROUPID"));
            obj.put("purchaseorderState", obj.get("PURCHASEORDERSTATE"));
            obj.put("purchaseorderFlowState", obj.get("PURCHASEORDERFLOWSTATE"));
            obj.put("purchaseorderCheckState", obj.get("PURCHASEORDERCHECKSTATE"));
            obj.put("erpSynState", obj.get("ERPSYNSTATE"));
            obj.put("createType", obj.get("CREATETYPE"));
            obj.put("viewFlag", obj.get("VIEWFLAG"));
            obj.put("erpReturnMsg", obj.get("ERPRETURNMSG"));
            obj.put("checkFirst", obj.get("CHECKFIRST"));
            obj.put("isViewPriceFlag", obj.get("ISVIEWPRICEFLAG"));
            obj.put("clientCode", obj.get("CLIENTCODE"));
            obj.put("remark", obj.get("REMARK"));
            obj.put("createId", obj.get("CREATEID"));
            obj.put("createName", obj.get("CREATENAME"));
            obj.put("createTime", obj.get("CREATETIME"));
            obj.put("modifyId", obj.get("MODIFYID"));
            obj.put("modifyName", obj.get("MODIFYNAME"));
            obj.put("modifyTime", obj.get("MODIFYTIME"));
            obj.put("purchasingGroupCode", obj.get("PURCHASINGGROUPCODE"));
            obj.put("purchasingGroupName", obj.get("PURCHASINGGROUPNAME"));
            obj.put("vendorerpCode", obj.get("VENDORERPCODE"));
            obj.put("isvendorView", obj.get("ISVENDORVIEW"));
            obj.put("receiveQty", obj.get("RECEIVEQTY"));
            obj.put("cansendQty", obj.get("CANSENDQTY"));
            obj.put("isrevocationCheck", obj.get("ISREVOCATIONCHECK"));
            obj.put("purchasingorgCode", obj.get("PURCHASINGORGCODE"));
            obj.put("returnValue", obj.get("RETURNVALUE"));
            obj.put("vendorconfirmTime", obj.get("VENDORCONFIRMTIME"));
            obj.put("internationlRradeterm", obj.get("INTERNATIONLRRADETERM"));
            obj.put("internationlRradeRemark", obj.get("INTERNATIONLRRADEREMARK"));
            obj.put("taxrateCode", obj.get("TAXRATECODE"));
            obj.put("orderReleaseTime", obj.get("ORDERRELEASETIME"));
            obj.put("urgent", obj.get("URGENT"));
            obj.put("contractNo", obj.get("CONTRACTNO"));
            obj.put("contractName", obj.get("CONTRACTNAME"));
            obj.put("projectNo", obj.get("PROJECTNO"));
            obj.put("projectName", obj.get("PROJECTNAME"));
            obj.put("engineeringNo", obj.get("ENGINEERINGNO"));
            obj.put("contacts", obj.get("CONTACTS"));
            obj.put("contactPhone", obj.get("CONTACTPHONE"));
            obj.put("taxrateValue", obj.get("TAXRATEVALUE"));
            obj.put("deliveryPlace", obj.get("DELIVERYPLACE"));
            obj.put("vendoragentId", obj.get("VENDORAGENTID"));
            obj.put("vendoragentCode", obj.get("VENDORAGENTCODE"));
            obj.put("vendoragentName", obj.get("VENDORAGENTNAME"));
            obj.put("projectStuffer", obj.get("PROJECTSTUFFER"));
            obj.put("projectStufferMail", obj.get("PROJECTSTUFFERMAIL"));
            obj.put("projectStufferPhone", obj.get("PROJECTSTUFFERPHONE"));
            obj.put("receiver", obj.get("RECEIVER"));
            obj.put("receiverMail", obj.get("RECEIVERMAIL"));
            obj.put("receiverPhone", obj.get("RECEIVERPHONE"));
            obj.put("budgetAmount", obj.get("BUDGETAMOUNT"));
            obj.put("promiseAmount", obj.get("PROMISEAMOUNT"));
            obj.put("actualAmount", obj.get("ACTUALAMOUNT"));
            obj.put("changeAmount", obj.get("CHANGEAMOUNT"));
            obj.put("contractAmount", obj.get("CONTRACTAMOUNT"));
            obj.put("otherCharge", obj.get("OTHERCHARGE"));
            obj.put("discountAmount", obj.get("DISCOUNTAMOUNT"));
            obj.put("paymenttypeCode", obj.get("PAYMENTTYPECODE"));
            obj.put("paymenttypeName", obj.get("PAYMENTTYPENAME"));
            obj.put("proposerCode", obj.get("PROPOSERCODE"));
            obj.put("proposer", obj.get("PROPOSER"));
            obj.put("subScriptionRatio", obj.get("SUBSCRIPTIONRATIO"));
            obj.put("workingScope", obj.get("WORKINGSCOPE"));
            obj.put("constructionPeriod", obj.get("CONSTRUCTIONPERIOD"));
            obj.put("receiverCode", obj.get("RECEIVERCODE"));
            obj.put("projectStufferCode", obj.get("PROJECTSTUFFERCODE"));
            obj.put("purchaseuserName", obj.get("PURCHASEUSERNAME"));
            obj.put("purchaseuserId", obj.get("PURCHASEUSERID"));
            obj.put("contractNoflag", obj.get("CONTRACTNOFLAG"));
            obj.put("subScription", obj.get("SUBSCRIPTION"));
            obj.put("changeNotaxAmount", obj.get("CHANGENOTAXAMOUNT"));
            obj.put("contractallNotaxAmount", obj.get("CONTRACTALLNOTAXAMOUNT"));
            obj.put("orderNotaxAmount", obj.get("ORDERNOTAXAMOUNT"));
            obj.put("auditorIds", obj.get("AUDITORIDS"));
            obj.put("materialKindCode", obj.get("MATERIALKINDCODE"));
            obj.put("updateTime", obj.get("UPDATETIME"));
            outDatas.add(obj);
        });
        resultBody.data(outDatas);
    }
}
